package com.hackaton.maps;

import android.content.Context;
import android.view.View;
import android.widget.Toast;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.hackaton.maps.transport.Route;

import java.util.ArrayList;
import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 * User: Ivan
 * Date: 20.10.13
 * Time: 4:36
 * To change this template use File | Settings | File Templates.
 */
public class MapHelper {

    private GoogleMap map;
    private static MapHelper instance = null;

    public HashMap<String, Route> routesTram = new HashMap<String, Route>();
    public HashMap<String, Route> routesTaxi = new HashMap<String, Route>();
    public HashMap<String, Route> routesTrol = new HashMap<String, Route>();

    public static MapHelper getInstance() {
        return instance;
    }

    public MapHelper(GoogleMap map, final Context context) {
        this.map = map;
        init(context);
        instance = this;

        ContentCreater.initTram(routesTram);
        ContentCreater.initTaxi(routesTaxi);
        ContentCreater.initTrol(routesTrol);

    }

    private GoogleMap init(final Context context) {
        // map.setMapType(GoogleMap.MAP_TYPE_NONE);
        map.setMyLocationEnabled(true);
        map.setTrafficEnabled(false);
        map.setIndoorEnabled(false);
        map.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
            @Override
            public View getInfoWindow(Marker marker) {
                Toast.makeText(context, "getInfoWindow", Toast.LENGTH_SHORT);
                return null;  //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public View getInfoContents(Marker marker) {
                Toast.makeText(context, "getInfoContents", Toast.LENGTH_SHORT);
                return null;  //To change body of implemented methods use File | Settings | File Templates.
            }
        });

        return map;
    }

    public void animateMapCamera(LatLng point, float zoom) {
        // map.moveCamera(CameraUpdateFactory.newLatLngZoom(point, zoom));
        map.animateCamera(CameraUpdateFactory.newLatLngZoom(point, zoom));
    }

    public GoogleMap getMap() {
        return map;
    }
}
